﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace TD.TheGame
{
    public abstract class CastleFence  : Sprite
    {
        public int MaxHealth
        {
            get;
            set;
        }

        public int Health
        {
            get;
            set;
        }

        public int Damage
        {
            get;
            set;
        }

        Rectangle[] hp100;
        Rectangle[] hp75;
        Rectangle[] hp50;
        Rectangle[] hp25;
        string name;

        public CastleFence(Game game, Vector2 position, bool active, int maxLoopTime, SpriteEnumState state)
            : base(game, position, active, maxLoopTime, state)
        {
            this.name = GetName();
            string path = (Environment.CurrentDirectory + "\\XML\\Fences\\" + name + "\\");
            hp100 = animationHandler.animationRec(path + "100.xml");
            hp75 = animationHandler.animationRec(path + "75.xml");
            hp50 = animationHandler.animationRec(path + "50.xml");
            hp25 = animationHandler.animationRec(path + "25.xml");
            current = hp100;
        }
        public abstract string GetName();
            //string name = "";
            //if (State == SpriteEnumState.Past)
            //{
            //    name = "game_fence1";
            //    Damage = 20;
            //}
            //if (State == SpriteEnumState.Normal)
            //{
            //    name = "game_fence2";
            //    Damage = 50;
            //}
            //if (State == SpriteEnumState.Future)
            //{
            //    name = "game_fence3";
            //}
            //return name;

        public override void Update(GameTime gameTime)
        {
            if (Active)
            {
                if (Health < MaxHealth * 0.75)
                {
                    current = hp75;
                }
                if (Health < MaxHealth * 0.5)
                {
                    current = hp50;
                }
                if (Health < MaxHealth * 0.25)
                {
                    current = hp25;
                }
                if (Health < 0)
                {
                    Active = false;
                }
            }
            base.Update(gameTime);
        }

        public override void Reset()
        {
            Health = 1000;
            State = SpriteEnumState.Past;
            Damage = 20;
        }
    }
}
